<template>
  <div class="comp" v-if="list.length > 0">
    <ul>
      <li v-for="item in list" :key="item.id" @click="gotoDetail(item.id)">
        <div class="img"></div>
        <img v-lazy="item.cover" alt="" />
        <div class="title">{{ item.title }}</div>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  props: {
    list: {
      type: Array,
      default() {
        return [];
      },
    },
  },
  methods: {
    gotoDetail(id) {
      this.$emit("gotoDetail", id);
    },
  },
};
</script>

<style lang="scss" scoped>
.comp {
  font-size: 16px;
  margin-bottom: 10px;
}
ul {
  margin-top: 20px;
  display: flex;
  justify-content: space-between;
  li {
    width: 30%;
    position: relative;
    .img {
      position: absolute;
      top: -12px;
      left: 0;
      z-index: 99;
      display: block;
      width: 100%;
      height: 44px;
      background-size: contain;
      background-repeat: no-repeat;
    }
    &:nth-child(1) {
      .img {
        background-image: url(../assets/images/icon_01.png);
      }
    }
    &:nth-child(2) {
      .img {
        background-image: url(../assets/images/icon_02.png);
      }
    }
    &:nth-child(3) {
      .img {
        background-image: url(../assets/images/icon_03.png);
      }
    }
    img {
      width: 100%;
      height: 90%;
    }
    .title {
      font-size: 16px;
      line-height: 1.2;
      margin: 4px 0;
      white-space: nowrap;
      text-overflow: ellipsis;
      overflow: hidden;
    }
  }
}
</style>
